package com.alex.springboot.controller;

import com.alex.springboot.mapper.PrivilegeMapper;
import com.alex.springboot.entity.Privilege;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/privilege")
public class PrivilegeController {

    @Autowired
    private PrivilegeMapper privilegeMapper;

    @PostMapping("/save")
    public Privilege save(@ModelAttribute Privilege privilege) {
        privilegeMapper.save(privilege);
        return privilege;
    }

    @GetMapping("{id}")
    public Privilege getById(@PathVariable Integer id) {
        return privilegeMapper.getById(id);
    }

    @GetMapping("/all")
    public List<Privilege> all() {
        return privilegeMapper.selectAll();
    }

}
